package com.example.test.controller;

import com.example.test.entity.Role;
import com.example.test.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired //@Resource也可以
    private RoleService roleService;
    @PostMapping("/list")
    public List<Role> list() {
        return roleService.findAll();
    }

    @PostMapping("/save")
    public String save(Role role) {
        int id = roleService.save(role);
        return "记录id为"+role.getId();
    }





}
